home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
snip9_91.arc
/
RM_ALL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-17
|
1KB
|
56 lines
/*
** remove all files
**
** public domain demo by Bob Stout
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <dos.h>
#define LAST_CHAR(str) (str[strlen(str) - 1])
#ifdef __TURBOC__
#define find_1st(n,a,b) (findfirst((n),(a),(b)))
#define find_nxt(b) (findnext(b))
#define ffblk ffblk
#elif defined(__ZTC__)
#define find_1st(n,a,b) (NULL == ((b) = findfirst((n),(a))))
#define find_nxt(b) (NULL == ((b) = findnext()))
#define ffblk FIND
#else /* assume MSC/QC */
#define find_1st(n,a,b) (_dos_findfirst((n),(a),(b)))
#define find_nxt(b) (_dos_findnext(b))
#define ffblk find_t
#endif
/* Select one of the following - remove() is ANSI */
#define rmfunc remove
/* #define rmfunc unlink */
main(int argc, char *argv[])
{
char rmpath[67], *rmfile;
struct ffblk *fbuf
#ifndef __ZTC__
= (struct ffblk *)malloc(sizeof(struct ffblk))
#endif
;
if (2 > argc)
strcpy(rmpath, ".\\");
else strcpy(rmpath, argv[1]);
if ('\\' != LAST_CHAR(rmpath))
strcat(rmpath, "\\");
rmfile = &rmpath[strlen(rmpath)];
strcpy(rmfile, "*.*");
if (0 == find_1st(rmpath, 0, fbuf)) do
{
strcpy(rmfile, fbuf->name);
rmfunc(rmpath);
} while (0 == find_nxt(fbuf));
}